<template lang="html">
  <div class="team_box">
    <div class="team_item" v-if="type === 'vip'">
      <div class="team_avatar">
        <img v-bind:src="item.user_avatar" class="team_img"/>
        <div class="is_vip" v-if="item.is_vip"></div>
      </div>
      <div class="item_info">
        <div class="info_name">{{item.user_nickname}}</div>
        <div class="info_time"><span class="tag" v-if="item.vip_relation">{{item.vip_relation}}邀请</span> <span>加入时间：{{item.create_time | dataSub }}</span></div>
      </div>
      <div class="info_contact">
        <div :class="item.user_wechart_qrcode ? 'contact_item contact_wechat' : 'contact_item contact_wechat disable' + ' ' " @click="joinWechat" :data-qrcode_img="item.user_wechart_qrcode"></div>
        <div class="contact_item contact_tel" @click="makePhoneCall" :data-tel="item.user_mobile"></div>
      </div>
      <van-dialog use-slot v-model="show_code" :showConfirmButton="false">
        <div class="team_code">
          <em class="close_dialog" @click="closeWechat"></em>
          <img class="qrcode" @touchstart="gtouchstart(this)" @touchmove="gtouchmove(this)" @touchend="gtouchend(this)" v-bind:src="item.user_wechart_qrcode"/>
          <p>长按图片可保存至相册</p>
        </div>
      </van-dialog>
    </div>
    <div class="team_item" v-if="type === 'fans'">
      <div class="team_avatar">
        <img v-bind:src="item.user_avatar" class="team_img"/>
        <!-- <div class="is_vip"></div> -->
      </div>
      <div class="item_info">
        <div class="info_name">{{item.user_nickname}}</div>
        <div class="info_time">加入时间：{{item.create_time | dataSub}}</div>
      </div>
      <div class="info_fans_contact">
        <div class="contact_order_num">订单成交{{item.order_count ? item.order_count : 0}}单</div>
        <!-- <div class="contact_tel" v-if="{{item.user_mobile}}">
          <div class="tel_icon"></div>
          <div>{{item.user_mobile}}</div>
        </div> -->
      </div>
    </div>
  </div>
</template>

<script>
import tools from '@/utils/tool'

var timeOutEvent = 0 // 定时器

export default {
  props: ['item', 'type'],
  data () {
    return {
      show_code: false
    }
  },
  mounted () {
    // console.log(this)
  },
  filters: {// 如下这样写
    dataSub: function (valueNum) { // valueNum就是我们需要的值
      return tools.dataSub(valueNum)// 返回给前台页面的值
    }
  },
  methods: {
    makePhoneCall (e) {
      if (e.target.dataset.tel) {
        window.location = 'tel:' + e.target.dataset.tel
      }
    },
    joinWechat (e) {
      if (e.target.dataset.qrcode_img) {
        this.show_code = true
        this.curr_qrcode = e.target.dataset.qrcode_img
      }
    },
    closeWechat (e) {
      this.show_code = false
    },
    gtouchstart (item) {
      var that = this
      timeOutEvent = setTimeout(function () {
        that.longPress()
      }, 1000)
      return false
    },
    gtouchend (item) {
      clearTimeout(timeOutEvent)
      // if(timeOutEvent!=0){
      // }
      return false
    },
    gtouchmove () {
      clearTimeout(timeOutEvent)
      timeOutEvent = 0
    },
    longPress () {
      timeOutEvent = 0
      console.log('yggsave://' + encodeURIComponent(this.curr_qrcode))
      window.location = 'yggsave://' + encodeURIComponent(this.curr_qrcode)
    }
  }
}
</script>

<style lang="css" scoped>
</style>
